package com.pdk.server;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SocketServer {
	public static final int COUNT = 10; // 10 room
	public static Map<Integer, List<DataOutputStream>> map = new HashMap<Integer, List<DataOutputStream>>(); // room
	public static List<DataOutputStream> userList = new ArrayList<DataOutputStream>();
	public static List<Map> list = new ArrayList<Map>(); // hall
	static {
		for (int i = 0; i < COUNT; i++) {
			HashMap room = new HashMap();
			room.put("id", i);
			room.put("name", "NO." + i + 1);
			list.add(room);
		}
	}

	public static void main(String[] args) {
		ServerSocket aServerSocket = null;
		try {
			aServerSocket = new ServerSocket(5555); // listen 5555 port.
			System.out.println("already listen 5555 port.");
		} catch (Exception e) {
			e.printStackTrace();
		}
		int num = 0;
		while (num < COUNT * 3) {
			try {
				Socket aSessionSoket = aServerSocket.accept();
				MyThread thread = new MyThread(aSessionSoket);
				thread.start();
				num++;
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
	}

}
